package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-19 21:07
 */
public class IsSubsequence {
    public boolean isSubsequence(String s, String t) {
        if (t.equals("")&&!s.equals("")) return false;
        char[] chars = t.toCharArray();
        char[] subChars = s.toCharArray();
        int temp = 0;
        for (int i = 0; i < subChars.length; i++) {
            if (temp==chars.length) return false;
            for (int j = temp; j < chars.length; j++) {
                if (chars[j] == subChars[i]) {
                    temp = j + 1;
                    break;
                }
                if (j==chars.length-1) return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        new IsSubsequence().isSubsequence("acb","ahbgdc");
    }
}
